package com.iwomy.envpro.platform.constant;

import cn.hutool.core.date.DateUnit;
import com.iwomy.envpro.platform.entity.*;

public enum TpEnum {
	REAl_TIME("RealTime","airRealTimeDataEntity", AirRealTimeDataEntity.class, DateUnit.SECOND.getMillis()),
	MINUTELY_AVG("MinutelyAvg","airMinutelyAvgDataEntity", AirMinutelyAvgDataEntity.class, DateUnit.MINUTE.getMillis()),
	HOURLY_AVG("HourlyAvg","airHourlyAvgDataEntity", AirHourlyAvgDataEntity.class, DateUnit.HOUR.getMillis()),
	DAILY_AVG("DailyAvg","airDayAvgDataEntity", AirHourlyAvgDataEntity.class, DateUnit.DAY.getMillis()),
	WEEKLY_AVG("WeeklyAvg","airHourlyAvgDataEntity", AirHourlyAvgDataEntity.class, DateUnit.WEEK.getMillis()),
	MONTHLY_AVG("MonthlyAvg","airMonthlyAvgDataEntity", AirMonthlyAvgDataEntity.class, DateUnit.WEEK.getMillis()),
	QUARTERLY_AVG("QuarterlyAvg","airQuarterlyAvgDataEntity", AirQuarterlyAvgDataEntity.class, DateUnit.WEEK.getMillis()),
	YEARLY_AVG("YearlyAvg","airHourlyAvgDataEntity", AirHourlyAvgDataEntity.class, DateUnit.WEEK.getMillis()),
	;
	private String code;
	private String name;
	private Class clazz;
	/**
	 * 时间间隔，用于报表数据分组统计
	 */
	private long interval;


	TpEnum(String code, String name,Class clazz,long interval) {
		this.code = code;
		this.name = name;
		this.clazz=clazz;
		this.interval=interval;
	}

	public String getCode() {
		return code;
	}

	public String getName() {
		return name;
	}

	public Class getClazz() {
		return clazz;
	}
	public long getInterval(){
		return interval;
	}

	public static TpEnum getInstance(String code) {
		for (TpEnum tpEnum : values()) {
			if (tpEnum.getCode().equals(code) ) {
				return tpEnum;
			}
		}
		return null;
	}
}
